<?php

	ini_set('post_max_size','1024M');
    ini_set('upload_max_filesize','1000M');   

	define('APP_ROOT','/nie-psd/api');
	define('YEE_URL_REWRITE',1);
	
	define('DB_HOST','localhost');
	define('DB_PORT','3306');
	define('DB_USER','root');
	define('DB_PWD','123456');
	define('DB_NAME','work');
	
	
	require 'Yee.php';
	
	Yee::import('db,nie,model');
	Yee::run(array(
		'init'=>init,
		'put'=>put,
		'delete'=>delete,
		'update'=>update,
		'upload'=>upload
	));
	
	function init(){}
	
	function upload(){
		Yee::import('upload');
		#config:
		$allowedExtensions = array('psd','zip');
		$sizeLimit = 1000 * 1024 * 1024;
		#create uploader:
		$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
		
		
		$result = $uploader->handleUpload('Yee-tmp/');
		
		if($result['success']){
			$storage=new Storage;
			$file=$uploader->getFile();
			if($storage->save('Yee-tmp/'.$file->uploadedName)){
				
				put(array(
						
					'pname'=>$file->getName(),
					'tag'=>getTags($file->getName()),
					'update'=>time(),
					'author'=>getAuthorFromIP(),
					'thumb'=>createPSDThumb(),
					'des'=>'',
					'project_id'=>'0'
				
				));
			
			}
		}
		

		
		echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
	}
	function put($psd=''){
		
		if(is_array($psd)){
			
			
		
		}
	
	}
	function delete($id){
		
		
	
	}
	function update($psd=''){
		
		if(is_array($psd)){
		
		
		}
	
	
	}


